Skip to content

feat: reverse_iterator support - #1474

Merged
SGSSGene merged 2 commits into
jbeder:masterfrom
sxrzh:reverse-iterator
Aug 10, 2026
Merged

feat: reverse_iterator support#1474
SGSSGene merged 2 commits into
jbeder:masterfrom
sxrzh:reverse-iterator

Conversation

@sxrzh

@sxrzh sxrzh commented Aug 1, 2026

Copy link
Copy Markdown
Contributor

Adds reverse_iterator support for YAML::Node, including:

  • Node::reverse_iterator and Node::const_reverse_iterator
  • Node::rbegin() and Node::rend(), including const versions

I didn't do the same for node_iterator, for I think node iterators won't be used directly and there're no systematic tests for node iterators.

Currently iterator_base and node_iterator_base are incompatible with std::reverse_iterator, since their operator->() function returns a proxy object, which could cause dangling pointer with std::reverse_iterator. So I implemented a customized reverse_iterator_base wrapper in yaml-cpp/node/detail/reverse_iterator.h .

@sxrzh

sxrzh commented Aug 1, 2026

Copy link
Copy Markdown
Contributor Author

So I implemented a customized reverse_iterator_base wrapper in yaml-cpp/node/detail/reverse_iterator.h .

Note that this does not meet the requirements for ReversibleContainer. Since the current YAML::Node is also far away from Container (maybe it is never intended to be), I think this is acceptable.

@SGSSGene SGSSGene left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Amazing! cool feature!

@SGSSGene
SGSSGene merged commit a8d5797 into jbeder:master Aug 10, 2026
46 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants